Skip to content

Phase 2: Replace NotebookLM with Gemini Deep Research API#630

Merged
codercatdev merged 10 commits intomainfrom
dev
Mar 5, 2026
Merged

Phase 2: Replace NotebookLM with Gemini Deep Research API#630
codercatdev merged 10 commits intomainfrom
dev

Conversation

@codercatdev
Copy link
Contributor

Phase 2: Replace NotebookLM with Gemini Deep Research API

All 6 tasks complete. Full pipeline swap from NotebookLM to Gemini.

What shipped:

PR Description
#624 SDK migration: @google/generative-ai@google/genai + Deep Research config fields
#625 New lib/services/gemini-research.ts — Interactions API client (submit/poll/parse)
#627 New lib/services/gemini-infographics.ts — Imagen 4 Fast infographic generation
#628 Rewrite check-research/route.ts — Gemini polling + inline infographic generation
#629 Update ingest/route.tssubmitResearch() replaces NotebookLM notebook creation

Pipeline flow:

  1. IngestsubmitResearch() → stores researchInteractionId → status: researching
  2. Check-researchpollResearch()parseResearchReport() → status: research_complete
  3. Check-researchgenerateInfographicsForTopic() → Sanity asset upload → status: enriching
  4. Check-research → enrichment prompt → status: script_ready

Build verification:

  • tsc --noEmit — zero errors
  • next build --webpack — compiled successfully (76s)
  • ⚠️ Pre-existing Algolia route fails page data collection without PRIVATE_ALGOLIA_ADMIN_API_KEY (same on main, works on Vercel)

Backward compatibility:

  • GROQ queries match both researchInteractionId (new) and researchNotebookId (legacy)
  • enableDeepResearch toggle — when disabled, researching docs skip to enriching
  • Legacy infographics_generating docs auto-advance to enriching
  • Old NotebookLM code still present (Task 7 cleanup after E2E verification)

codercatdev and others added 10 commits March 5, 2026 09:58
Moves hardcoded INFOGRAPHIC_INSTRUCTIONS to contentConfig.infographicInstructions array field. Alex can now add/remove/reorder prompts in Sanity Studio.
- Replace @google/generative-ai with @google/genai (new SDK with Interactions API support)\n- Lazy-init GoogleGenAI client in lib/gemini.ts\n- Migrate gemini-intent.ts and gemini-outreach.ts to new SDK\n- Add pipelineConfig fields: enableDeepResearch, deepResearchAgent, deepResearchPromptTemplate, infographicModel\n- Add matching TypeScript types to PipelineConfig interface\n\nUnblocks Sprint 2: Gemini Deep Research client + infographic generation service.
New Gemini Deep Research client using @google/genai Interactions API.\n\nExports: submitResearch, pollResearch, parseResearchReport, conductGeminiResearch.\nAll models/prompts from Sanity config. Two-phase parsing (Gemini Flash + regex fallback).\nBackward-compatible ResearchPayload output.
New infographic generation service using Imagen 4 Fast via @google/genai SDK.\n\nExports: generateInfographic, generateInfographicBatch, generateInfographicsForTopic, buildInfographicPrompt.\nModel + instructions from Sanity config. Deterministic seeds for brand consistency.\nPer-item fault isolation. ~$0.10 per topic (5 images).
Rewrite check-research cron route to use Gemini Deep Research + Imagen 4 Fast.\n\n- Replace NotebookLM polling with pollResearch() from gemini-research.ts\n- Replace NotebookLM infographic generation with generateInfographicsForTopic() from gemini-infographics.ts\n- Infographics now generated synchronously (no more async polling step)\n- enableDeepResearch toggle: skip to enriching when disabled\n- Legacy migration handler for docs stuck in infographics_generating\n- Backward compat: GROQ query matches both researchInteractionId and researchNotebookId\n- buildResearchPayload detects full ResearchPayload shape and passes through directly\n- Net -125 lines
Replace NotebookLM with Gemini Deep Research in ingest cron route.\n\n- Replace NotebookLM imports/calls with submitResearch() from gemini-research.ts\n- Gate behind enableDeepResearch config (was enableNotebookLmResearch)\n- Store researchInteractionId on automatedVideo doc\n- Add researchInteractionId field to automatedVideo Sanity schema\n- Keep old researchNotebookId/researchTaskId fields for backward compat\n- Fire-and-forget pattern preserved (submit, don't poll)
@vercel
Copy link

vercel bot commented Mar 5, 2026

Deployment failed with the following error:

Resource is limited - try again in 6 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/alex-pattersons-projects?upgradeToPro=build-rate-limit

@codercatdev codercatdev merged commit 3b6284f into main Mar 5, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant